﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZyGames.Framework.Game.Service;
using ZyGames.Framework.Game.Sns;

namespace GameServer.Script.CsScript.Action
{
    public class Action101 : BaseStruct
    {
        private string passportID = string.Empty;
        private string password = string.Empty;
        private string deviceId = string.Empty;
        public Action101(ActionGetter actionGetter)
            : base(101, actionGetter)
        {
        }

        /// <summary>
        /// 客户端请求的参数较验
        /// </summary>
        /// <returns>false:中断后面的方式执行并返回Error</returns>
        public override bool GetUrlElement()
        {
            if (httpGet.GetString("passportID", ref passportID) &&
                httpGet.GetString("password", ref password))
            {
                httpGet.GetString("DeviceID", ref deviceId);
                return true;
            }
            return false;
        }

        /// <summary>
        /// 业务逻辑处理
        /// </summary>
        /// <returns>false:中断后面的方式执行并返回Error</returns>
        public override bool TakeAction()
        {
            //int userId = 
            SnsManager.Register(passportID, password, deviceId, true);
            Console.WriteLine("注册成功");
            return true;
        }
        /// <summary>
        /// 下发给客户的包结构数据
        /// </summary>
        public override void BuildPacket()
        {
            PushIntoStack(passportID);
            PushIntoStack(password);
        }
    }
}
